package cn.funeralobjects.asms.converter;

import cn.funeralobjects.utils.aliyun.sms.enums.TemplateType;

import javax.persistence.AttributeConverter;

/**
 * Converter of TemplateType
 *
 * @author FuneralObjects
 * Create date: 2020/5/31 9:01 PM
 */
public class TemplateTypeConverter implements AttributeConverter<TemplateType, Short> {
    @Override
    public Short convertToDatabaseColumn(TemplateType attribute) {
        return attribute == null ? null : attribute.getNum();
    }

    @Override
    public TemplateType convertToEntityAttribute(Short dbData) {
        return dbData == null ? TemplateType.OTHER : TemplateType.of(dbData);
    }
}
